#!/usr/bin/env python
# -*- coding: utf-8 -*-

#
# This program is free software; you can redistribute it and/or modify  
# it under the terms of the GNU General Public License as published by  
# the Free Software Foundation; either version 2 of the License, or     
# (at your option) any later version.                                   
#                                                                         
# A copy of the license can be found in the license.txt file supplied   
# with this software or at: http://www.gnu.org/copyleft/gpl.html       
#


from memtable import Memtable


class   ColumnFamilyStore(object) :
    def __init__(self, table_name, column_family_name) :
        self.table_name = table_name
        self.column_family_name = column_family_name

        self._memtable = Memtable(self.table_name, self.column_family_name)
        ## __init__()


    def apply(self, row_key, column_family, commit_log_context) :
        '''insert/update the column family for the row_key
        '''
        
        # TODO : to switch memtable
        if self._memtable.isThresholdViolated() :
            self._memtable.flush( commit_log_context )

        self._memtable.put(row_key, column_family)
        ## apply()

    ## class ColumnFamilyStore()


